package jsu.blogger.mapper;


import jsu.blogger.pojo.UserStats;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserStatsMapper {
    @Insert("insert blog_system_database.user_stats(user_id, ranking, email)" +
            " value (#{userId},#{userId},#{email})")
    void insertUserStats(@Param("userId") Long userId,@Param("email") String email);

    @Select("select blog_system_database.user_stats.user_id from blog_system_database.user_stats where email=#{email}")
    Long selectUIdByEmail(String email);

    @Select("select * from blog_system_database.user_stats where user_id=#{UID}")
    @Results({
            @Result(property = "userId",column = "user_id"),
            @Result(property = "followersCount",column = "followers_count"),
            @Result(property = "followingCount",column = "following_count"),
            @Result(property = "visitCount",column = "visit_count"),
            @Result(property = "Ranking",column = "ranking")
    })
    UserStats selectUserStatsByUID(Long UID);

    @Update("update blog_system_database.user_stats set sex=#{sex} where user_id=#{userId}")
    void updateSexByUserId(@Param("sex") int sex,@Param("userId") Long userId);
    @Update("update blog_system_database.user_stats set email=#{email} where user_id=#{userId}")
    void setUserEmail(@Param("email") String email,@Param("userId") Long userId);

    @Select("select blog_system_database.user_stats.email from blog_system_database.user_stats where user_id=#{userId}")
    String getEmail(Long userId);
}
